//
//  ASTableViewController.swift
//  weiboBlog
//
//  Created by asenter on 16/3/27.
//  Copyright © 2016年 asenter. All rights reserved.
//

import UIKit

class ASTableViewController: UITableViewController {
    
    //用户是否登陆
    var useLogin = false

    override func viewDidLoad() {

        useLogin ? super.viewDidLoad() : setVisitView()
        
    }
    
   
    //设置访客视图
    func setVisitView() {
        
        view = visitorView
        
        //设置访客视图代理
        //当设置代理后，必须实现代理协议: UITableViewController, CZVisitorViewDelegate
        visitorView.delegate = self
        
        if self is HomeViewController {
            
           visitorView.startRotation()
            
        }else if self is MessageViewController {
            
            visitorView.setVisitor("visitordiscover_image_message", message: "登录后，别人评论你的微博，发给你的消息，都会在这里收到通知")
            
        }else if self is DiscoverViewController {
            
            visitorView.setVisitor("visitordiscover_image_message", message: "登录后，最新、最热微博尽在掌握，不再会与实事潮流擦肩而过")
            
        }else if self is ProfileViewController {
            
            visitorView.setVisitor("visitordiscover_image_profile", message: "登录后，你的微博、相册、个人资料会显示在这里，展示给别人")
            
        }
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidClickResgistButton")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登陆", style: UIBarButtonItemStyle.Plain, target: self, action: "visitorViewDidClickLoginButton")
        
//        view.backgroundColor = UIColor.grayColor()
    }
  
    lazy var visitorView: ASVisitorView = ASVisitorView()
}

extension ASTableViewController: ASVisitorViewDelegate {
    
    func visitorViewDidClickResgistButton() {
        print("正在注册")
    }
    
    func visitorViewDidClickLoginButton() {
        print("正在登陆")
    }
    
}



